#include<iostream>
#include<vector>
#include<string>
using namespace std;

void Check_Sort(vector<string> words)
{
	if (words.size() == 0)
	{
		cout << "none" << endl;
		return;
	}

	if (words.size() == 1)
	{
		cout << "both" << endl;
		return;
	}

	bool length_sort = true, alphabet_sort = true;
	string pword = words[0];
	for (int i = 1; i < words.size(); i++)
	{
		if (pword.length() > words[i].length())
			length_sort = false;
		if (pword > words[i])
			alphabet_sort = false;
		pword = words[i];
	}

	if (length_sort && alphabet_sort)
		cout << "both" << endl;
	else if (length_sort)
		cout << "lengths" << endl;
	else if (alphabet_sort)
		cout << "islexicalorder" << endl;
	else
		cout << "none" << endl;
}

int main()
{
	int num;
	vector<string> words;
	cout << "请输入字符串个数：";
	cin >> num;
	cout << endl << "请输入" << num << "个字符串:" << endl;
	while (num--)
	{
		string word;
		cin >> word;
		words.push_back(word);
	}
	cout << endl;
	Check_Sort(words);

	return 0;
}